package com.example.demo.repository;

import com.example.demo.entity.BookType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;


@Repository
public interface BookTypeRepository extends JpaRepository<BookType, Integer> {
    Optional<BookType> findByName(String name);

    // 添加模糊搜索方法
    @Query("SELECT bt FROM BookType bt WHERE bt.name LIKE %:name%")
    List<BookType> findByNameContaining(@Param("name") String name);
}